<template>
	<view class="">
		<view v-if="type == 1">
			<video id="myVideo" class="video-view" :src="video" @error="videoErrorCallback" enable-danmu danmu-btn
				controls></video>
		</view>
		<view v-if="type == 2">
			<u-swiper :list="imgList" img-mode="aspectFit" :height="windowHeight"
				@click="previewImage" current ="0" :autoplay="false"></u-swiper>
		</view>
	</view>
</template>

<script>
	import {
		goodsdetail
	} from '@/api/home.js'

	export default {
		data() {
			return {
				video: '',
				id: '',
				img: '',
				imgList: [],
				windowHeight: 0,
				_data: {}
			}
		},
		onLoad(options) {
			
			this.type = options.type
			if (this.type == 1) {
				this.video = options.video
				uni.setNavigationBarTitle({
					title: '宣传片'
				})
			}
			if (this.type == 2) {
				this.id = options.id
				this.getDetail(this.id)
			}
			var that = this;
			uni.getSystemInfo({
				//调用uni-app接口获取屏幕高度
				success(res) {
					//成功回调函数
					that.windowHeight = (res.windowHeight - 84) * 2
				}
			});
		},
		methods: {
			getDetail(id) {
				goodsdetail({
					cate_id: id
				}).then(res => {
					console.log(res.data, 'daaaaa')
					this.imgList = res.data.photos
				})
			},
			previewImage(index) {
				console.log(index, 'index')
				uni.previewImage({
					urls: this.imgList,
					current: index
				});
			}
		}

	}
</script>

<style>
	.video-view {
		width: 100%;
	}
</style>